package com.itheima.bos.web.action.system;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.itheima.bos.domain.system.Permission;
import com.itheima.bos.service.system.IPermissionService;
import com.itheima.bos.web.action.base.BaseAction;
import com.opensymphony.xwork2.ActionContext;


/**
 * 权限的action
 * @author yanju
 *
 */
@ParentPackage("json-default")
@Namespace("/")
@Scope("prototype")
@Controller
public class PermissionAction extends BaseAction<Permission>{
	
	@Autowired
	private IPermissionService permissionServiceImpl;
	
	@Action(value="permission_list",results={@Result(name="success",type="json")})
	public String permission_list(){
		
		List<Permission> resluts=permissionServiceImpl.findAll();
		
		ActionContext.getContext().getValueStack().push(resluts);
			
		return "success";
	}

	/*
	 * 添加权限的action
	 */
	@Action(value="permission_save",results={@Result(name="success",type="redirect",location="/pages/system/permission.html")})
	public String permission_save(){
		permissionServiceImpl.save(model);
		
		return SUCCESS;
	}
}	
